/*
 ============================================================================
 Name        : i3_2013_ISBN_10.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


	/*Testen von SVNNN*/
//test eugen alex

int pruefziff_10(char* isbn_num)
{
	int i, len, summe=0, summe11=0, gew=2;
	len= strlen(isbn_num);
	/*Zahl von hinten durchlaufen.*/
	for(i=len-1; i>=0;i--)
	{
		printf("%i. isbn_num = %i, gew = %d\n",i,isbn_num[i]-48,gew);/*0 ist in dder Ascii-tab an der Stelle 48(dez)*/

		summe= summe+(isbn_num[i]-48)*gew;
		gew++;
	}
	summe11=summe % 11;

	return 11- summe11;
}

int pruefziff_13(char* isbn_num)
{
	int i, len, summe=0, gew=0;
	len= strlen(isbn_num);
	for(i=len-1; i>=0;i--)
	{
		if(i%2==0) gew = 1;
		if(i%2==1) gew = 3;
		printf("%i. isbn_num = %i, gew = %d\n",i,isbn_num[i]-48,gew);


		summe= summe+(isbn_num[i]-48)*gew;
		printf("summe = %i\n",summe);
	}
	//summe11=summe % 11;

	return 10 - (summe%10);
}


	//puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
	//return EXIT_SUCCESS;

int main(){

	long long i;//=400330101839;

	printf("%lld\n\n",i);

	printf("pz = %d\n",pruefziff_10("157231422"));
	printf("*****************************************\n");
	printf("pz = %d\n",pruefziff_13("400330101839"));
	//printf("pz = %d\n",pruefziff_13("762220000460"));
	return 0;
}

